<template>
  <div>
    <div class="homebar" @click="goParticulars">
      <div v-if="newsList.type == 1 && newsList.cover.length >= 3" class="threeImg">
        <div class="title">
          <p>{{newsList.title}}</p>
        </div>
        <div class="center">
          <img :src="newsList.cover[0].url" alt />
          <img :src="newsList.cover[1].url" alt />
          <img :src="newsList.cover[2].url" alt />
        </div>
        <div class="foot">
          <p>
            <span>{{newsList.user.nickname}}</span>
            <span>
              {{newsList.comment_length}}
              <em>跟帖</em>
            </span>
          </p>
        </div>
      </div>
      <div v-else-if="newsList.type == 1 && newsList.cover.length <= 1" class="oneImg">
        <div class="left">
          <p>{{newsList.title}}</p>
          <div class="foot">
            <p>
              <span>{{newsList.user.nickname}}</span>
              <span>
                {{newsList.comment_length}}
                <em>跟帖</em>
              </span>
            </p>
          </div>
        </div>
        <div class="right">
          <img :src="newsList.cover[0].url" alt />
        </div>
      </div>
      <div v-else-if="newsList.type == 2" class="oneVideo">
        <div class="title">
          <p>{{newsList.title}}</p>
        </div>
        <div class="video">
          <img :src="newsList.cover[0].url" alt />
          <span class="iconfont iconshipin"></span>
        </div>
        <div class="foot">
          <p>
            <span>{{newsList.user.nickname}}</span>
            <span>
              {{newsList.comment_length}}
              <em>跟帖</em>
            </span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: ["newsList"],
  methods: {
    goParticulars(){
      this.$emit('goParticulars')
    }
  },
};
</script>

<style lang="less" scoped>
.homebar {
  padding: 2.222vw;
  p {
    font-size: 4.444vw;
  }
  // 共同底部
  .foot {
    color: #868686;
    span {
      padding-right: 5.556vw;
      em {
        padding-left: 0.833vw;
      }
    }
  }
  // 三图片
  .threeImg {
    display: flex;
    flex-direction: column;
    justify-content: center;
    .center {
      height: 19.444vw;
      padding: 1.389vw 0;
      display: flex;
      justify-content: space-between;
      img {
        width: 33%;
      }
    }
  }
  //单图片
  .oneImg {
    display: flex;
    justify-content: space-between;
    .left {
      display: flex;
      flex-direction: column;
      justify-content: space-between;
    }
    .right {
      width: 30%;
      img {
        width: 28.055vw;
        height: 18.056vw;
      }
    }
  }
  // 视频
  .oneVideo {
    display: flex;
    flex-direction: column;
    .video {
      display: flex;
      position: relative;
      img {
        width: 100%;
        height: 50vw;
      }
      .iconshipin {
        width: 13.889vw;
        height: 13.889vw;
        line-height: 13.889vw;
        text-align: center;
        font-size: 13.889vw;
        color: white;
        background: #cccccc;
        border-radius: 50%;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
      }
    }
  }
}
</style>